﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 装饰模式
{
    /// <summary>
    /// 装饰抽象类，要让装饰完全取代抽象组件，所以必须继承自Photo
    /// </summary>
    public abstract class Decorator : Phone
    {
        private Phone phone;
        public Decorator(Phone p)
        {
            this.phone = p;
        }
        public override void Print()
        {
            if (phone != null)
            {
                phone.Print();
            }
        }
    }

    //贴膜。具体的装饰类1
    public class Sticker : Decorator
    {
        public Sticker(Phone p) : base(p)
        { }
        public override void Print()
        {
            base.Print();
            AddSticker();
        }

        public void AddSticker()
        {
            Console.WriteLine("现在苹果手机有贴膜了");
        }
    }
    //手机挂件，具体的装饰类2
    public class Accessories : Decorator
    {
        public Accessories(Phone p) : base(p)
        {
        }
        public override void Print()
        {
            base.Print();
            AddAccessories();
        }

        public void AddAccessories()
        {
            Console.WriteLine("现在苹果手机有漂亮的挂件了");
        }
    }
}
